#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=(x<<1)+(x<<3)+ch-48,ch=getchar();}
	return x*f;
}
int n,q,l,r,m,pre[N],suf[N],cnt[N],Ans;
string t;

signed main(){
	freopen("good.in","r",stdin);
	freopen("good.out","w",stdout);
	n=read(),q=read();
	cin>>t;t=' '+t;
	while(q--){
		l=read(),r=read();
		int sum=0,ans=0;
		for(int i=l;i<=r;i++) cnt[i]=0;
		for(int i=l;i<=r;i++){
			sum+=(t[i]=='1')?1:-1;
			if(sum==-1){
				sum=0;
				cnt[i]=1;
				ans++;
			}
		}
		for(int i=r;i>=l;i--){
			sum+=(t[i]=='1')?1:-1;
			if(sum==-1) sum=0,ans++;
			sum+=cnt[i];
		}
		Ans^=ans;
	}	
	printf("%d",Ans);
	return 0;
}
